package pl.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import pl.model.dao.BookDao;

@Controller
public class ListBooksController {

	protected final Log logger = LogFactory.getLog(getClass());
	
	protected BookDao bookDao;
	
        @RequestMapping("/listBooks.htm")
	public ModelAndView handleRequest(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		logger.debug("ListBooksController " + bookDao);
		
		List books = bookDao.getAll();
		
		ModelAndView mav = new ModelAndView("listBooks", "books", books);
		
		return mav;
	}

	public void setBookDao(BookDao bookDao) {
		this.bookDao = bookDao;
	}

}
